function dispatch(name, detail) {
  const event = new CustomEvent(name, {
    detail,
  })
  window.dispatchEvent(event)
}

function listen(name, callback) {
  window.addEventListener(name, callback)
  return () => {
    window.removeEventListener(name, callback)
  }
}
export default {
  dispatch,
  listen,
}
